<template>
	<view>
		<view class="header status_bar" :class="scrrol == true ? 'scrrolHeader' : ''">
			<view class="back iconfont icon-xiangzuo1" @tap="backPage"></view>
			<view class="text" :class="scrrol == true ? 'scrrolHeader' : ''">我的账户</view>
		</view>	
		<view class="bg_box">
			<image class="bg01" :src="getImgSrc('/static/bg02.png')" mode="widthFix"></image>
			<view class="bg_content">
				<block v-for="(item, index) in info" :key="index">
				<view class="bank_list">
					<view class="name_box">
						<view class="icon">
							<image src="../../../static/bank01.png" mode="widthFix"></image>
						</view>
						<view class="name">{{item.bank_name}}</view>
						<view class="menu" @click="unbind(item.id)">解绑</view>
					</view>
					<view class="num_box">
						<view class="num">{{item.bank_no}}</view>
						<view class="text">借记卡</view>
					</view>
					<view class="bank_img">
						<image src="../../../static/bank05.png" mode="widthFix"></image>
					</view>
				</view>
				</block>
				
				<!-- <view class="bank_list bank_list02">
					<view class="name_box">
						<view class="icon">
							<image src="../../../static/bank02.png" mode="widthFix"></image>
						</view>
						<view class="name">中国工商银行</view>
						<view class="menu">解绑</view>
					</view>
					<view class="num_box">
						<view class="num">•••• •••• •••• 6688</view>
						<view class="text">借记卡</view>
					</view>
					<view class="bank_img">
						<image src="../../../static/bank06.png" mode="widthFix"></image>
					</view>
				</view>
				
				<view class="bank_list bank_list03">
					<view class="name_box">
						<view class="icon">
							<image src="../../../static/bank03.png" mode="widthFix"></image>
						</view>
						<view class="name">中国工商银行</view>
						<view class="menu">解绑</view>
					</view>
					<view class="num_box">
						<view class="num">•••• •••• •••• 6688</view>
						<view class="text">借记卡</view>
					</view>
					<view class="bank_img">
						<image src="../../../static/bank07.png" mode="widthFix"></image>
					</view>
				</view> -->
				
			</view>
		</view>
		
		<view class="confirm" :data-url="'/pages/personalcenter/bank/add'" @click="gotopage">添加银行卡</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page:1,
				scrrol:false,
				info:'',
				
			}
		},
		onLoad() {
			let that = this;
			that.loadData();
		},
		onShow() {
			let that = this;
			let bank_load = uni.getStorageSync('bank_load');
			if (bank_load){
				that.loadData();
			}
		},
		methods: {
			setRule(e){
				let that = this;
				let index = e.currentTarget.dataset.index;
				that.flowList[index].tick = !that.flowList[index].tick
			},
			loadData() {
				let that = this;
				that.Net._get('auth/card_list', {per_page:'10',page:that.page,}, res => {
					if (res.code == 200) {
						that.info = res.data.data;
					}
				});
			},
			unbind(id){
				let that = this;
				that.Net._get('auth/card_delete', {id:id}, res => {
					if (res.code == 200) {
						that.Msg.Success('解绑成功', res => {
							that.loadData();
						});
						uni.setStorageSync('bank_load', 1);
					}
				});
			},
			backPage() {
				uni.navigateBack({});
			},
			gotopage(e) {
				let url = e.currentTarget.dataset.url;
				uni.navigateTo({
					url: url
				});
			},

		},
		onPageScroll: function(Object) {
			//console.log(Object.scrollTop); //实时获取到滚动的值
			if (Object.scrollTop > 28) {
				this.scrrol = true;
				/* #ifdef APP-PLUS */
				/* #endif */
			} else if (Object.scrollTop < 28) {
				this.scrrol = false;
				/* #ifdef APP-PLUS */
				/* #endif */
			}
		},
		onReachBottom() {
			var that = this;
			that.page++;
			that.Net._get('auth/card_list', {per_page:'10',page:that.page,}, res => {
				if (res.code == 200) {
					//console.log(res)
					if (res.data.data == '') {
						uni.showToast({
							title: '已经是最后一页了',
							duration: 2000,
						icon: 'none'
						});
					} else {
						that.info = that.info.concat(res.data.data); //将数据拼接在一起
					}
				} else if (res.code == 0) {
					that.Msg.Success(res.msg, res => {});
				}
			});
		},
	}
</script>

<style>
	
	.header{
		background-color: transparent !important;
	}
	
	.header .text{
		background-color: transparent !important;
		color: #333 !important;
	}
	
	.header .back{
		color: #333 !important;
	}
	
	.scrrolHeader{
		background-color: #F9E9E3 !important;
	}
	
	.bg_box{
		width: 100%;
		position: relative;
	}
	
	.bg_box .bg01{
		width: 100%;
	}
	
	.bg_box .bg_content{
		width: 92%;
		position: absolute;
		left: calc(50% - 46%);
		top: calc(13.5vw + var(--status-bar-height));
		z-index: 98;
	}
	
	.bank_list{
		width: 100%;
		background-color: #FF535B;
		padding: 5vw 4%;
		position: relative;
		border-radius: 3vw;
		margin-top: 4%;
	}
	
	.bank_list02{
		background-color: #4392F7;
	}
	
	.bank_list03{
		background-color: #0DC39E;
	}
	
	.bank_list .name_box{
		display: flex;
		align-items: center;
	}
	
	.bank_list .name_box .icon{
		width: 8vw;
		margin-right: 2vw;
	}
	
	.bank_list .name_box .icon image{
		width: 100%;
	}
	
	.bank_list .name_box .name{
		font-size: 4vw;
		color: #fff;
		font-weight: bold;
		flex: 1;
	}
	
	.bank_list .name_box .menu{
		width: 12vw;
		font-size: 3.8vw;
		height: 8vw;
		color: #fff;
		border: 1px solid #fff;
		border-radius: 8vw;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	
	.bank_list .num_box{
		width: 100%;
		padding-left: 10vw;
		margin-top: 3vw;
	}
	
	.bank_list .num_box .num{
		font-size: 6vw;
		color: #fff;
		font-weight: bold;
	}
	
	.bank_list .num_box .text{
		font-size: 3.5;
		color: #fff;
		margin-top: 3vw;
	}
	
	.bank_list .bank_img{
		width: 30vw;
		position: absolute;
		right: 0;
		bottom: 0;
	}
	
	.bank_list .bank_img image{
		width: 100%;
	}
	
	
	
</style>
